<template>
    <el-form ref="loginRefForm" :model="ActivityQuery">
        <el-form-item label="Id">
            {{ ActivityQuery.id }}
        </el-form-item>
        <el-form-item label="ownerId">
            {{ ActivityQuery.ownerId }}
        </el-form-item>
        <el-form-item label="name">
            {{ ActivityQuery.name }}
        </el-form-item>
        <el-form-item label="startTime">
            {{ ActivityQuery.startTime }}
        </el-form-item>
        <el-form-item label="endTime">
            {{ ActivityQuery.endTime }}
        </el-form-item> <el-form-item label="cost">
            {{ ActivityQuery.cost }}
        </el-form-item>
        <el-form-item label="createTime">
            {{ ActivityQuery.createTime }}
        </el-form-item>
        <el-form-item label="description">
            {{ ActivityQuery.description }}
        </el-form-item>

        <el-form-item label="">
            <el-input v-model="ActivityQuery.Remark" type="textarea" :rows="5" placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-form-item label="">
            <el-button type="primary" @click="$router.go(-1)">返回</el-button>
        </el-form-item>

        <el-form-item label="">
            <el-button type="primary" @click="sureRemark()">确认备注</el-button>
        </el-form-item>
    </el-form>

    <el-table :data="activeRemarkDataList" style="width: 100%">
        <el-table-column type="index"  label="序号" value="id" width="120"></el-table-column>
        <el-table-column property="noteContent" label="备注内容" width="120" />
        <el-table-column property="createTime" label="备注时间" width="120" />
        <el-table-column property="createByDO.name" label="备注人" width="120" />
    </el-table>
    <el-pagination background layout="prev, pager, next" :total=total :page-size=pageSize @change="changePage" />
    
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
import Request from '../http/Request';
import router from '../router/router';
const ActivityQuery= ref({
    id: '',
    ownerId: '',
    name: '',
    startTime: '',
    endTime: '',
    cost: '',
    createTime: '',
    description: '',
    Remark: ''
})

const remarkData=ref({
    activityId:'',
    noteContent:'',
    editByDo:''
});

const pageSize= ref(10)
const total=ref(0)
const currentPage=ref(1)
const activeRemarkDataList=ref([])

const changePage = (page) => {
    currentPage.value = page
}

const sureRemark = () => {
    let id = router.currentRoute.value.params.id
    remarkData.value.activityId=id
    remarkData.value.noteContent=ActivityQuery.value.Remark
    Request.doPost('/api/activity/remark',{}, remarkData.value).then((res) => {
        if (res.code == 200) {
            ElMessage({
                message: '备注成功',
                type: 'success',
            })
            router.go(-1)
        }
    })
}

onMounted(() => {
    
    loadActivityData()
    loadActivityRemarkData()
    

})

const loadActivityData= () => {
    let id=router.currentRoute.value.params.id
   console.log(id)
    Request.doGet('/api/activity/' + id).then((res) => {
        if (res.code == 200) {
            ActivityQuery.value=res.data
            console.log(ActivityQuery.value)

        }
        
    })

}
const loadActivityRemarkData= () => {
    Request.doGet('/api/activity/remark' ,{
        current: currentPage.value,
        activityId: parseInt(router.currentRoute.value.params.id),
    }).then((res) => {
        if (res.code == 200) {
            activeRemarkDataList.value=res.data.list
            total.value=res.data.total
            pageSize.value=res.data.pageSize
            console.log(res.data)
            console.log(remarkData.value)
            console.log(total.value)
            console.log(pageSize.value)

        }
        
    })

    
}




</script>

<style scoped></style>

